package com.example.myenglishbook.database;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface WordsDao {
    @Insert
    void insert(Words... words);
    @Update
    void update(Words... words);
    @Delete
    void delete(Words... words);
    @Query("SELECT * FROM WORDS ORDER BY words_id DESC")
    LiveData<List<Words>> queryAll();
    @Query("DELETE FROM WORDS")
    void clear();
    @Query("SELECT * FROM WORDS WHERE words_name LIKE :patten OR words_meaning LIKE :patten ORDER BY words_id DESC")
    LiveData<List<Words>> findWordsWithPatten(String patten);
}
